import request from '@/utils/request'

// 查询设备检测列表
export function listDetect(query) {
  return request({
    url: '/real/detect/list',
    method: 'get',
    params: query
  })
}

//查询设备状态
export function getStatus() {
  return request({
    url: '/real/detect/status',
    method: 'get'
  })
}

//查询设备检测详情
export function getDetectInfo(){
  return request({
    url: '/real/detect/info',
    method: 'get'
  })
}

// 查询设备检测详细
export function getDetect(timestamp) {
  return request({
    url: '/real/detect/' + timestamp,
    method: 'get'
  })
}

// 新增设备检测
export function addDetect(data) {
  return request({
    url: '/real/detect',
    method: 'post',
    data: data
  })
}

// 修改设备检测
export function updateDetect(data) {
  return request({
    url: '/real/detect',
    method: 'put',
    data: data
  })
}

// 删除设备检测
export function delDetect(timestamp) {
  return request({
    url: '/real/detect/' + timestamp,
    method: 'delete'
  })
}

// 获取设备加速度数据
export function getAccelerationData(deviceId) {
    return request({
        url: '/real/detect/info',
        method: 'get',
        params: {
            deviceId
        }
    })
}

// 查询WebSocket连接状态
export function getWebSocketStatus() {
  return request({
    url: '/real/detect/websocket/status',
    method: 'get'
  })
}

// 订阅设备加速度数据
export function subscribeAccelerationData(deviceId, latheName) {
  return request({
    url: '/real/detect/websocket/subscribe',
    method: 'post',
    data: {
      deviceId,
      latheName,
      dataType: 'acceleration'
    }
  })
}

// 取消订阅设备加速度数据
export function unsubscribeAccelerationData(deviceId) {
  return request({
    url: '/real/detect/websocket/unsubscribe',
    method: 'post',
    data: {
      deviceId,
      dataType: 'acceleration'
    }
  })
}
